import cv2 as cv
import numpy as np
import seaborn as sns
import matplotlib.pyplot as plt
from PyCmpltrtok.common import sep


def checkGaussianKernel(ksize, sp_params):
    assert ksize % 2

    sep(ksize)

    sp_params[-1] += 1
    plt.subplot(*sp_params)
    plt.title(f'{ksize}')
    kernel = cv.getGaussianKernel(ksize, -1)
    sns.heatmap(kernel, annot=True)
    print(kernel)
    print(kernel.sum())

    sp_params[-1] += 1
    plt.subplot(*sp_params)
    plt.title(f'{ksize}')
    plt.plot(kernel)


if '__main__' == __name__:

    def _main():
        plt.figure(figsize=[9, 8])
        plt.subplots_adjust(wspace=0.5)
        sp_params = [4, 4, 0]
        for ksize in [3, 5, 7, 9, 11, 13, 15]:
            checkGaussianKernel(ksize, sp_params)
        plt.show()

    _main()
